package com.me.study.concurrent.queue;

import java.util.Comparator;
import java.util.concurrent.PriorityBlockingQueue;

/**
 * 优先级的阻塞队列：PriorityBlockingQueue
 *
 * @author ME
 * @date   2020/1/9
 */
public class TestPriorityBlockingQueue {

    private final PriorityBlockingQueue<Integer> queue = new PriorityBlockingQueue<>(11, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o2 - o1;
        }
    });

    public static void main(String[] args) throws InterruptedException {
        TestPriorityBlockingQueue test = new TestPriorityBlockingQueue();
        test.queue.put(10);
        test.queue.put(6);
        test.queue.put(15);
        test.queue.put(3);
        System.out.println(test.queue.take());

    }
}
